import { Message } from 'element-ui'
import axios from '../http'
import utils from './utils'
export function cheeToken(){
      // 输出
    var flag = null;
    console.log('进入SSO checkToken...');
    var toToken = null;
    if(!localStorage.getItem('token')){
        //没有token就无效  就显示登陆页面
        return Promise.resolve("invalid")
    }
    toToken=localStorage.getItem('token');
    console.log("SSO toToken===" + toToken)
    if (toToken) {
         //checkTokenCookie
        flag=axios.get('/api/pureCheckToken').then((res) => {
            if (res.data.code == "200") {
                console.log("SSO TOKEN 有效。"+res.data.code+"---"+res.data.message);
                return Promise.resolve("valid")
                //return "ok";
            } else {
                //localStorage.removeItem('token')
                console.log("SSO TOKEN 无效");
                return Promise.resolve("invalid")
            }
        }).catch((err) => {
            //Message.error(response.data.message);
            //return Promise.reject(err);
            console.log("carch Error 请求失败。。。");
            return Promise.resolve("invalid");
        })
    } 
    return flag;
}
